import { AstContext } from "../../../context";
import { Pages } from "../Pages";
import { PageVisitor } from "../pageVisitor";
import { createToIndex } from "./createToIndex";
import { createToTitle } from "./createToTitle";
export interface FollowContext {
    toFollowTab: (index: number) => boolean;
    toFollowTabTitle: (title: string) => boolean;
    followTabIndex: number;
    followTab: string;
}
// visitFrameLayout R.follow_selector_layout_root
// 推荐排序|时间排序|只看朋友 关注下拉选择框
export function parseFollowSelectorLayoutRoot(visitor: PageVisitor, ast: AutoJs.UiObject, ctx: AstContext): boolean {
    const node = ctx.bfsOne(ast, (node) => node.className() === `androidx.recyclerview.widget.RecyclerView`)
    if (node) {
        if (node.visibleToUser()) {
            ctx.set(`currentPage`, Pages.homeFollowSelect)
            ctx.set(`toFollowTab`, createToIndex(node, ctx, 'followTabIndex'))
            ctx.set(`toFollowTabTitle`, createToTitle(node, ctx, 'followTab'))
            ctx.eachChild(ast, (it, index) => {
                const selected = it.selected()
                if (selected) {
                    ctx.set('followTabIndex', index)
                    ctx.set('followTab', ctx.getText(it))
                }
            })
        }
    }
    return true;
}
